//
//  YFEmoji.swift
//  Emoji
//
//  Created by 余仿 on 16/4/18.
//  Copyright © 2016年 yf. All rights reserved.
//

import UIKit

class YFEmoji: NSObject {

    //MARK:字符串格式的表情
    var chs:String?

    //MARK:表情对应的图片名
    var png:String?{

        didSet{
            //拼接绝对路径

            imagePath = NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + "\(id!)" + "/" + "\(png ?? "")"

        }
    }

    //表情的绝对路径
    var imagePath:String?

    //每组表情对应的文件夹名
    var id:String?

    //emoji表情对应的字符串
    var code:String?{

        didSet{

            emojiStr = code?.emoji2Str()
            
        }
    }

    var emojiStr:String?

    //字典转模型
    init(id:String,dict:[String:AnyObject]) {

        self.id = id

        super.init()

        setValuesForKeysWithDictionary(dict)
    }

    //过滤不需要的字段
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {

    }


    var isEmpty:Bool = false

    init(isEmpty:Bool) {

        self.isEmpty = isEmpty
        
        super.init()
    }


    var isDelete:Bool = false

    init(isDelete:Bool) {

        self.isDelete = isDelete

        super.init()
    }

    override var description: String {
        let keys = ["chs","png","code"]
        let dict = self.dictionaryWithValuesForKeys(keys)
        return dict.description
    }
    
    
}
